<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of HouseModel
 *
 * @author yaoyunhua
 */
namespace Admin\Model;
use Think\Model\RelationModel;

class AdverPlaceRecordModel  extends RelationModel {
    //put your code here
    protected  $tableName = 'adver_place_record';
    protected $_auto = array (
        array('add_time','time',2,'function'), // 对add_time字段在tj添加"时候写入当前时间戳
    );
    protected $_link = array(
        'Adv'=>array(
            'mapping_type' => self::BELONGS_TO,
            'class_name'  => 'adver_place',
            'mapping_name' => 'adverplaces',
            'foreign_key' =>  'pid',
            'parent_key'  => 'id'
        ),
    );
   //获取广告列表
    public function getAdvList(){
        $data =  $this->relation(true)->where(array('status'=>1))->select();
        return $data;

    }
    //删除广告
    public function delAdv($advId,$data=array()){
        return $this->where(array('id'=>$advId))->save($data);
    }
    //编辑广告
    public function getAdvInfoById($advId){
        return $this->where("id = ".$advId)->find();
    }
}